package com.woniu.user.mapper;

import com.woniu.user.pojo.UserArticleCollection;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 用户收藏表 Mapper 接口
 * </p>
 *
 * @author 何荣卓
 * @since 2023-02-17
 */
public interface UserArticleCollectionMapper extends BaseMapper<UserArticleCollection> {

    @Select("select * from t_user_article_collection where user_id = #{id} and article_id = #{articleId}")
    UserArticleCollection selectIsAttention(@Param("id") String id, @Param("articleId") String articleId);

    @Update("UPDATE t_user_article_collection SET is_deleted = 0 WHERE user_id = #{id} and article_id = #{articleId} AND is_deleted = 1")
    int updateIsDeleted(@Param("id") String id, @Param("articleId") String articleId);

    @Update("UPDATE t_user_article_collection SET is_deleted = 1 WHERE user_id = #{id} and article_id = #{articleId} AND is_deleted = 0")
    int rmlikeArticle(@Param("id") String id, @Param("articleId") String articleId);
}
